package br.com.core;

import java.applet.Applet;

public class Game03Test extends Applet implements Runnable {

	private Thread animator;
	private volatile boolean running = false;

	public void init() {
	}

	public void start() {
		if (animator == null) {
			animator = new Thread(this, "Thread principal");
		}
		animator.start();
		System.out.println("Start");
	}

	public void stop() {
		if (animator != null) {
			setRunning(false);
			animator = null;
			System.out.println("Stop");
		}
	}

	private synchronized void setRunning(boolean running) {
		this.running = running;
	}

	private synchronized boolean isRunning() {
		return running;
	}

	@Override
	public void run() {
		setRunning(true);

		while (isRunning()) {
/*
			gameUpdate(); // game state is updated
			gameRender(); // render to a buffer
			paintScreen();*/

			try {
				Thread.sleep(10);
			} catch (Exception e) {
			}
		}

	}

}
